//
//  BackPassword_OneViewController.m
//  O2O Product
//
//  Created by 特沃兹 on 2017/12/29.
//  Copyright © 2017年 Product Author. All rights reserved.
//

#import "BackPassword_OneViewController.h"

@interface BackPassword_OneViewController ()

@end

@implementation BackPassword_OneViewController

#pragma mark - ---------- Lazy Loading（懒加载） ----------
-(TextFieldView *)PhoneText
{
    if (_PhoneText == nil) {
        _PhoneText = [[TextFieldView alloc]initWithFrame:CGRectMake(20, 50+TopBarHeight, Main_Screen_Width-40, 50)];
        _PhoneText.backgroundColor = [UIColor clearColor];
        _PhoneText.layer.borderWidth = 1;
        _PhoneText.layer.borderColor = [ChangeColor hexStringToColor:@"d2d2d2"].CGColor;
        [_PhoneText.leftIcon setImage:[UIImage imageNamed:@"Login_Phone"] forState:UIControlStateNormal];
        _PhoneText.placeholderString = @"请输入手机号码";
        _PhoneText.maxTextLength = 11;
        _PhoneText.layer.cornerRadius = 2;
        _PhoneText.TextF.keyboardType = UIKeyboardTypePhonePad;
    }
    return _PhoneText;
}
-(TextFieldView *)ValidationText
{
    if (_ValidationText == nil) {
        _ValidationText = [[TextFieldView alloc]initWithFrame:CGRectMake(20, 50+TopBarHeight, Main_Screen_Width-100, 50)];
        _ValidationText.backgroundColor = [UIColor clearColor];
        _ValidationText.layer.borderWidth = 1;
        _ValidationText.layer.borderColor = [ChangeColor hexStringToColor:@"d2d2d2"].CGColor;
        [_ValidationText.leftIcon setImage:[UIImage imageNamed:@"Login_Validation"] forState:UIControlStateNormal];
        _ValidationText.placeholderString = @"请输入验证码";
        _ValidationText.maxTextLength = 6;
        _ValidationText.layer.cornerRadius = 2;
        _ValidationText.TextF.keyboardType = UIKeyboardTypePhonePad;
    }
    return _ValidationText;
}
-(UIButton *)ValidationButton{
    if (_ValidationButton == nil) {
        _ValidationButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_ValidationButton setBackgroundColor:[ChangeColor hexStringToColor:@"f0f0f0"]];
        [_ValidationButton setTitle:@"验证码" forState:UIControlStateNormal];
        [_ValidationButton setTitleColor:Color_999999 forState:UIControlStateNormal];
        [_ValidationButton.layer setCornerRadius:2];
        [_ValidationButton.layer setBorderWidth:1];
        [_ValidationButton.layer setBorderColor:[ChangeColor hexStringToColor:@"d2d2d2"].CGColor];
        [_ValidationButton addTarget:self action:@selector(ValidationAction) forControlEvents:UIControlEventTouchUpInside];
        
    }
    return _ValidationButton;
}
-(UIButton *)NextStepButton{
    if (_NextStepButton == nil) {
        _NextStepButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_NextStepButton setBackgroundColor:Color_d73b3c];
        [_NextStepButton setTitle:@"下一步" forState:UIControlStateNormal];
        [_NextStepButton setTitleColor:Color_ffffff forState:UIControlStateNormal];
        [_NextStepButton.layer setCornerRadius:2];
        [_NextStepButton addTarget:self action:@selector(NextStepAction) forControlEvents:UIControlEventTouchUpInside];
    }
    return _NextStepButton;
}
#pragma mark - ----------   Lifecycle（生命周期） ----------
-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self.view setBackgroundColor:[UIColor whiteColor]];
    
    [self InitSubView];

}
-(void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
}
-(void)viewDidDisappear:(BOOL)animated
{
    [super viewDidDisappear:animated];
}
#pragma mark - ---------- Private Methods（私有方法） ----------

#pragma mark initliaze data(初始化数据)

#pragma mark config control（布局控件）
-(void)InitSubView{
    [self.view  addSubview:self.PhoneText];
    [self.PhoneText mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_offset(0);
        make.size.mas_offset(CGSizeMake(Main_Screen_Width-40, 50));
        make.top.mas_offset(TopBarHeight+50);
    }];
    [self.view addSubview:self.ValidationButton];
    [self.ValidationButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.PhoneText.mas_bottom).offset(10);
        make.right.equalTo(self.PhoneText.mas_right).offset(0);
        make.size.mas_offset(CGSizeMake(194/2, 50));
    }];
    [self.view  addSubview:self.ValidationText];
    [self.ValidationText mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.PhoneText.mas_bottom).offset(10);
        make.left.equalTo(self.PhoneText.mas_left).offset(0);
        make.right.equalTo(self.ValidationButton.mas_left).offset(-10);
        make.bottom.equalTo(self.ValidationButton.mas_bottom).offset(0);
    }];
    [self.view addSubview:self.NextStepButton];
    [self.NextStepButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_offset(0);
        make.top.equalTo(self.ValidationButton.mas_bottom).offset(20);
        make.size.mas_offset(CGSizeMake(Main_Screen_Width-40, 50));
    }];
}
#pragma mark networkRequest (网络请求)



#pragma mark IBActions （点击事件xib）
-(void)ReturnViewAction{
    /*返回上一页*/
    [self dismissViewControllerAnimated:YES completion:nil];
}
//验证码
-(void)ValidationAction{
    /*1.验证码图片点击刷新；
     2.验证码有效期5分钟*/
    [self dismissViewControllerAnimated:YES completion:nil];

}
//下一步
-(void)NextStepAction{
    /*
     1.当手机号及验证码为空时呈灰态，点击判断手机号为空飘字“请输入手机号”，验证码为空飘字“请输入图形验证码”；
     2.两者不为空时先校验手机号格式，错误飘字“请输入正确的手机号！”；
     3.其次校验验证码，错误飘字“请输入正确的图形验证码”；
     4.验证码无误接下来校验手机号是否注册，未注册飘字“手机号未注册”，刷新验证码；
     5.无误后进入下一步
     */
    [self presentViewController:[BackPassword_TwoViewController new] animated:YES completion:nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
